<?php
define('IN_D', true);
define('IN_D_ADMIN', true);
include("../includes/_config.php");
include("../includes/_functions.php");
include("../includes/_class_form.php");
$func = new func;
$level=0;

if(!empty($_SESSION['admin_id']))
	$level = $func->check_level($_SESSION['admin_id']);
	/*
if (!empty($_GET['act']) == 'backup' && !empty($_POST['submit']) && $level == 1) {
	include("_dbbackup.php");
	exit();
}
*/
if(!empty($_POST['key_search'])){
include("_ajax.php");
exit();
}

function acp_setcookie($name, $value = '', $permanent = true) {
	global $conf;
	$expire = ($permanent)?(time() + 60 * 60 * 24 * 365):0;
 @setcookie($name,$value,$expire);
}


if(empty($_POST['language_acp'])){
	if(empty($_COOKIE['lang_pack_acp'])){
	acp_setcookie('lang_pack_acp', "vi");
	$_COOKIE['lang_pack_acp']="vi";
	}
}
elseif($_POST['language_acp']){
acp_setcookie('lang_pack_acp', $_POST['language_acp']);
}
$se_acp_en=($_COOKIE['lang_pack_acp']=='en')?'selected="selected"':'';
$se_acp_vi=($_COOKIE['lang_pack_acp']=='vi')?'selected="selected"':'';

include("language/".$_COOKIE['lang_pack_acp'].".php");
$form = new HTMLForm;
?>
<html>
<head>
<?php if (!empty($_GET['act']) == 'left') echo '<base target="frame_content">'; ?>
	<title>.: <?php $webTitle?> CP :.</title>
	<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
	<link rel=stylesheet href="style.css" type=text/css>
</head>
<?php if (!$level) { ?>
<form method="post" action="login.php">
<table width=31% align=center cellpadding=2 cellspacing=0 class=border bgcolor=white>
	<tr><td colspan=2 align=center class=title>Đăng nhập</td></tr>
	<tr><td width=48% class=fr>Tên đăng nhập</td><td width=52% class=fr_2><input name="name" type="text" size="20"></td></tr>
	<tr><td class=fr>Mật khẩu</td><td class=fr_2><input name="password" type="password" size="20"></td></tr>
	<tr><td class=fr colspan=2 align=center><input class="submit" type="submit" name="submit" value="Đăng nhập"></td></tr>
</table>
</form>
<?php
	exit();
}
include("acp_functions.php");
if ($level == 2) $mod_permission = acp_get_mod_permission();
$link = 'index.php';
if ($_SERVER["QUERY_STRING"]) $link .= '?'.$_SERVER["QUERY_STRING"];
?>
<script src="../js/acp_js.js" type="text/javascript"></script><script src="../js/him.js"></script>
<?php
if (!empty($_GET['act'])) echo '<table cellspacing="0" align="center" cellpadding="0" width="100%"><tr><td align="center" width="100%">';
$mode=(!empty($_GET['mode']))?$_GET['mode']:'';
$act=(!empty($_GET['act']))?$_GET['act']:'';
$pg=(!empty($_GET['pg']) && is_numeric($_GET['pg']))?$_GET['pg']:'';
$search = (!empty($_GET['search']))?(trim(urldecode($_GET['search']))):'';
switch($act){
	case "cat":		include("_cat.php");break;
	case "news":	include("_news.php");break;
	case "tpl":		include("_tpl.php");break;
	case "ads":		include("_ads.php");break;
	case "user":	include("_user.php");break;
	case "config":	include("_configures.php");break;
	case "site_off":	include("_siteoff.php");break;
	case "server":	include("_server.php");break;
	case "mod_permission":	include("_mod_permission.php");break;
	case "main"	:	echo "Dmedia Cpanel"; break;
	case "header" :	echo "<div class=title><b>Control Panel</b></div>";break;
	case "left"	:	include("_left.php");break;
	case "focus"	: 	include("_focus.php");break;
	case "backup"	: 	include("_dbbackup.php");break;
	default :
		echo '<script type="text/javascript">if (self.parent.frames.length != 0) self.parent.location.replace(document.location.href);</script>';
?>
	<frameset cols="200,*" rows="*" id="mainFrameset">
		<frame src="index.php?act=left" name="frame_navigation" frameborder="0" noresize />
		<frameset rows="20,*">
			<frame src="index.php?act=header" frameborder="0" noresize />
			<frame src="index.php?act=main" name="frame_content" id="frame_content" frameborder="0" noresize />
		</frameset>
	</frameset>
<?php
		break;
}
if (!empty($_GET['act'])) echo '</td></tr></table>';

?>
</html>
